package com.boot.study.common;

import com.boot.study.exceptions.ServiceException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler({ServiceException.class})
    @ResponseBody
    public Result handleServiceException(ServiceException serviceException){
     return Result.builder().code(serviceException.getCode()+"").msg(serviceException.getMsg()).build();
    }
}
